nodes = {}

def addr_to_ident(addr):
    ip, port = addr
    local = ('#' + str(port & 0xffff)) if port & 0x10000 else str(port)
    return  local + '@' + ip

def ident_to_addr(ident):
    local, ip = ident.split('@')
    port = (int(local[1:]) | 0x10000) if local.startswith('#') else int(local)
    return (ip, port)
